﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConfigCreate
{
    /// <summary>
    /// 通过检查指定属性的值来控制本控件可见性（可多设置）
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
    public class CreateVisibilityPanelAttribute : Attribute
    {
        /// <summary>
        /// 通过检查指定属性的值来控制本控件可见性（可多设置）
        /// </summary>
        /// <param name="relevance_propertie_name">关联的属性</param>
        /// <param name="check_value">对比关联的属性的值</param>
        /// <exception cref="ConfigException">任意参数为空时报错</exception>
        public CreateVisibilityPanelAttribute(string relevance_propertie_name, object check_value)
        {
            if (string.IsNullOrEmpty(relevance_propertie_name))
                throw new ConfigException("检查属性名不能为空");
            if (check_value == null)
                throw new ConfigException("检查对比值不能为空");
            RelevancePropertieName = relevance_propertie_name;
            CheckValue = check_value;
        }



        /// <summary>
        /// 关联的属性
        /// </summary>
        public string RelevancePropertieName { get; set; }
        /// <summary>
        /// 对比关联的属性的值
        /// </summary>
        public object CheckValue { get; set; }
        /// <summary>
        /// 判断条件是否反转
        /// </summary>
        public bool IsReversal { get; set; }

        /// <summary>
        /// 控制的大类别名（可选）
        /// </summary>
        public string? RelevanceHeaderName { get; set; }
        /// <summary>
        /// 控制的组名（可选）
        /// </summary>
        public string? RelevanceGroupName { get; set;}
    }
}
